﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace CLFramework.Infrastructure.PlugIns
{
    public static class MethodInfoExtensions
    {
        /// <summary>
        /// 检查方法中时候包含[Async]
        /// </summary>
        /// <param name="method"></param>
        /// <returns></returns>
        public static bool IsAsync(this MethodInfo method)
        {
            if (method == null)
                return false;

            AsyncAttribute[] asyncAtts = (AsyncAttribute[])method.GetCustomAttributes(typeof(AsyncAttribute), true);
            if (asyncAtts == null || asyncAtts.Length == 0 || !(bool)asyncAtts[0].Value)
                return false;

            return true;
        }
    }
}
